# Maintainer: Jelle van der Waa <jelle@archlinux.org>

_hkgname=tz
pkgname=haskell-tz
pkgver=0.1.3.6
pkgrel=69
pkgdesc='Efficient time zone handling'
arch=(loong64 x86_64)
url='https://github.com/ysangkok/haskell-tz'
license=(BSD)
depends=(ghc-libs haskell-vector haskell-data-default haskell-tzdata)
checkdepends=(haskell-tasty haskell-tasty-th haskell-hunit haskell-quickcheck
              haskell-tasty-quickcheck haskell-tasty-hunit)
makedepends=(ghc uusi)
source=("https://hackage.haskell.org/packages/archive/$_hkgname/$pkgver/$_hkgname-$pkgver.tar.gz")
sha512sums=('d9b7b8964dbaa1bb4d9f805e01d3029313c676743b28c336d17ae98bb984ad8671a1712e9b927588b823ece68805eec8d637f3d8161cb3b63cfc0e609e3c7df3')

prepare() {
  cd $_hkgname-$pkgver
  uusi -u vector $_hkgname.cabal
}

build() {
  cd $_hkgname-$pkgver
    
  runhaskell Setup configure -O --enable-shared --enable-executable-dynamic --disable-library-vanilla \
    --prefix=/usr --docdir=/usr/share/doc/$pkgname --datasubdir=$pkgname \
    --dynlibdir=/usr/lib --libsubdir=\$compiler/site-local/\$pkgid --ghc-option=-fllvm \
    --enable-tests \
    --ghc-option=-optl-Wl\,-z\,relro\,-z\,now \
    --ghc-option='-pie'

  runhaskell Setup build $MAKEFLAGS
  runhaskell Setup register --gen-script
  runhaskell Setup unregister --gen-script
  sed -i -r -e "s|ghc-pkg.*update[^ ]* |&'--force' |" register.sh
  sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh
}

check() {
  cd $_hkgname-$pkgver
  runhaskell Setup test --show-details=direct
}

package() {
  cd $_hkgname-$pkgver

  install -D -m744 register.sh "$pkgdir"/usr/share/haskell/register/$pkgname.sh
  install -D -m744 unregister.sh "$pkgdir"/usr/share/haskell/unregister/$pkgname.sh
  runhaskell Setup copy --destdir="$pkgdir"
  install -D -m644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
  rm -f "$pkgdir"/usr/share/doc/$pkgname/LICENSE
}

# vim: ts=2 sw=2 et:
